<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>图书列表</title>
</head>
<body>
	<div align="center">
		<h3>图书列表</h3>
		<h4 id="status"></h4>

		<!--freemarker判断是否为空-->
		<#if host??>
			<table cellpadding="10">
				<tr>
					<td>${host.name}</td>
					<td><a href="/login/logout/do">退出登录</a></td>
				</tr>
			</table>
			<#else>
				<h5>未登录！<a href="/login/login">登陆/</a><a href="/login/register">注册</a></h5>
		</#if>

		<table border="1" cellpadding="10">
			<tr>
				<td>ID</td>
				<td>书名</td>
				<td>作者</td>
				<td>价格</td>
				<td>状态</td>
				<td colspan="2" align="center"><a href="/book/addbook" target="_blank">添加图书</a></td>
			</tr>

			<!--这个是freemarker的列表语法#list, freemaker的取值表达式不能再注解中使用-->
			<#list books as book>
				<tr>
				  <td><a>${book.id}</a></td>
				  <td>《${book.name}》</td>
				  <td>${book.author}</td>
				  <td>${book.price}</td>

					<!--freemarker的语法和java不同，if开头，if结尾，中间不结尾-->
					<!--#if-#elseif-#else正确结构如此-->
					<td>
						<#if book.status == 0>
							在库
						<#elseif book.status == 1>
							已借出
						</#if>
					</td>
				  <td><a href="/book/${book.id}/delete">借书</a></td>
				  <td><a href="/book/${book.id}/recover">还书</a></td>
				</tr>
			</#list>
		</table>
	</div>
</body>
</html>
